

#include "DDCPItemTypes.hpp"
#include "DDCPItem.hpp"
#include <stdio.h>
#include <string.h>

// #define defineDDCPItems(_enum, _name) _name
#define defineDDCPItems(_enum ) #_enum

const char* CDDCPItemTypes::s_DDCPTags[MAXDDCPType] = {
    defineDDCPItems( SeriesNumber ),
    defineDDCPItems( ResType ),
    defineDDCPItems( OperateType ),
    defineDDCPItems( PileNo ),
    defineDDCPItems( Roadway ),
    defineDDCPItems( Action ),
    defineDDCPItems( Variable ),
    defineDDCPItems( Name ),
    defineDDCPItems( Address ),
    defineDDCPItems( Message ),
    defineDDCPItems( FileType ),
    defineDDCPItems( MaxFileNum ),
    defineDDCPItems( BeginTime ),
    defineDDCPItems( EndTime ),
    defineDDCPItems( Query ),
    defineDDCPItems( BitRate ),
    defineDDCPItems( Priority ),
    defineDDCPItems( GOP ),
    defineDDCPItems( Notify ),
    defineDDCPItems( Format ),
    defineDDCPItems( Video ),
    defineDDCPItems( Audio ),
    defineDDCPItems( MaxBitrate ),
    defineDDCPItems( ReceiveSocket ),
    defineDDCPItems( DecoderTag ),
    defineDDCPItems( Control ),
    defineDDCPItems( PTZCommand ),
    defineDDCPItems( Level ),
    defineDDCPItems( AlarmType ),
    defineDDCPItems( AcceptPort ),
    defineDDCPItems( AcceptIp ),
    defineDDCPItems( Response ),
    defineDDCPItems( Result ),
    defineDDCPItems( RealFileNum ),
    defineDDCPItems( SendFileNum ),
    defineDDCPItems( FileInfolist ),
    defineDDCPItems( PlanListInfo ),
    defineDDCPItems( Item ),
    defineDDCPItems( FileSize ),
    defineDDCPItems( Playurl ),
    defineDDCPItems( Online ),
    defineDDCPItems( Status ),
    defineDDCPItems( Protocol ),
    defineDDCPItems( FileName ),
    defineDDCPItems( FileNum ),
    defineDDCPItems( UserCode ),
    defineDDCPItems( TransmitMode ),
    defineDDCPItems( Multicast ),
    defineDDCPItems( PTZResult ),
    defineDDCPItems( SendSocket ),
    defineDDCPItems( FreeSpace ),
    defineDDCPItems( CurrentRecord ),
    defineDDCPItems( CurrentVOD ),
    defineDDCPItems( MaxRecord ),
    defineDDCPItems( MaxVOD ),
    defineDDCPItems( TotalSpace ),
    defineDDCPItems( CameraAddress ),
    defineDDCPItems( FrameRate ),
    defineDDCPItems( Time ),
    defineDDCPItems( RemainFileNum ),
    defineDDCPItems( PlanName ),
    defineDDCPItems( OverWrite ),
    defineDDCPItems( Usage ),
    defineDDCPItems( RemainPlanNum ),
    defineDDCPItems( SendPlanNum ),
    defineDDCPItems( RealPlanNum ),
    defineDDCPItems( StartTime ),
    defineDDCPItems( PlayType ),
    defineDDCPItems( PlanStatus ),
    defineDDCPItems( Parent ),
    defineDDCPItems( SubNum ),
    defineDDCPItems( SubList ),
    defineDDCPItems( Privilege ),
    defineDDCPItems( Longitude ),
    defineDDCPItems( Latitude ),
    defineDDCPItems( Elevation ),
    defineDDCPItems( PlanType ),
    defineDDCPItems( CreationTime ),
    defineDDCPItems( LastWriteTime ),
    defineDDCPItems( ControlResponse ),
    defineDDCPItems( QueryResponse ),
    defineDDCPItems( Command ),
    defineDDCPItems( FileInfoList ),
    defineDDCPItems( Plan ),
    defineDDCPItems( PlanListDo ),
    defineDDCPItems( ResSubType )
};


#undef defineDDCPItems


const char* CDDCPItemTypes::get( EDDCPType type ){
    const char* ret = NULL;
    if ( UNKNOWN < type && type < MAXDDCPType ){
        ret = s_DDCPTags[type];
    }
    return ret;
}


CDDCPItemTypes::EDDCPType CDDCPItemTypes::getType( const char* str ){
    if( !str ) return UNKNOWN;

    CDDCPItemTypes::EDDCPType type = UNKNOWN;
    for ( int i = 0; i < MAXDDCPType; i++ ){
        if ( 0 != ::strcmp( s_DDCPTags[i], str )){
            continue;
        } else{
            type = ( CDDCPItemTypes::EDDCPType )i;
            break;
        }
    }
    return type;
}

